package com.lanou.beautifulwardrobe.brand.adapter;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lanou.beautifulwardrobe.R;
import com.lanou.beautifulwardrobe.entify.EditRecommendProduct;
import com.lanou.beautifulwardrobe.brand.EditViewPager;

import java.util.List;

/**
 * Created by dllo on 15/10/31.
 */
public class EditViewPagerFragment extends Fragment {
    private EditViewPager viewPagerAdapter;
    private ViewPager viewPager;
    private List<EditRecommendProduct> datas;
    public EditViewPagerFragment(List<EditRecommendProduct> datas) {
        this.datas = datas;

    }
    @Override
    public void onAttach(Context context) {

    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.dialog_viewpager, null);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        viewPager = (ViewPager) view.findViewById(R.id.dialogViewpager);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Log.i("lanou", "事实上事实上");
        viewPagerAdapter = new EditViewPager(getChildFragmentManager());
        if (datas != null && datas.size() > 0) {
            viewPagerAdapter.addData(datas);
        }
        viewPager.setAdapter(viewPagerAdapter);
    }
}
